package pers.cz.selenium.component;

import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;

/**
 * @program: PostGirl-panent
 * @description: 按钮控件
 * @author: Cheng Zhi
 * @create: 2022-12-27 17:03
 **/
public class ButtonComponent extends AbstractComponent {

    private RemoteWebDriver driver;
    private WebElement webElement;

    public ButtonComponent(String fullXPath, RemoteWebDriver driver) {
        this.driver = driver;
        this.webElement = driver.findElementByXPath(fullXPath);
        init();
    }

    @Override
    public WebElement initWebElement() {
        return webElement;
    }

    @Override
    public RemoteWebDriver initDriver() {
        return driver;
    }

    /**
     * 回车触发按钮
     */
    public void setEnter() {
        webElement.sendKeys(Keys.ENTER);
    }
}
